package com.hulk.dryad.manage.framework.websocket.server.cluster;


import com.hulk.dryad.manage.framework.websocket.server.config.WebSocketServerConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessagingTemplate;

/**
 * websocket 服务端集群配置
 *
 * @author
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(WebSocketServerConfiguration.class)
@AutoConfigureAfter(WebSocketServerConfiguration.class)
@ConditionalOnProperty(
	name = "enabled",
	prefix = ClusterWebSocketProperties.PREFIX,
	havingValue = "true",
	matchIfMissing = true
)
public class ClusterWebSocketConfiguration {

	@Bean
	public ClusterWebSocketSender clusterWebSocketSender(SimpMessagingTemplate messagingTemplate) {
		return new ClusterWebSocketSender(messagingTemplate);
	}

}
